package com.zc.operator.service.impl;

import java.util.List;
import java.util.Map;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zc.operator.mapper.ChargeStationMapper;
import com.zc.operator.domain.ChargeStation;
import com.zc.operator.service.IChargeStationService;

import static com.ruoyi.common.utils.SecurityUtils.getDeptId;
import static com.ruoyi.common.utils.SecurityUtils.getUsername;

/**
 * 场站Service业务层处理
 *
 * @author glb
 * @date 2023-05-17
 */
@Service
public class ChargeStationServiceImpl implements IChargeStationService
{
    @Autowired
    private ChargeStationMapper chargeStationMapper;

    /**
     * 查询场站
     *
     * @param chargeStationId 场站主键
     * @return 场站
     */
    @Override
    @DataScope(deptAlias = "d")
    public ChargeStation selectChargeStationByChargeStationId(Long chargeStationId)
    {
        return chargeStationMapper.selectChargeStationByChargeStationId(chargeStationId);
    }

    /**
     * 查询场站列表
     *
     * @param chargeStation 场站
     * @return 场站
     */
    @Override
    @DataScope(deptAlias = "d")
    public List<ChargeStation> selectChargeStationList(ChargeStation chargeStation)
    {
        return chargeStationMapper.selectChargeStationList(chargeStation);
    }

    /**
     * 新增场站
     *
     * @param chargeStation 场站
     * @return 结果
     */
    @Override
    public int insertChargeStation(ChargeStation chargeStation)
    {
        chargeStation.setDeptId(getDeptId());
        chargeStation.setCreateBy(getUsername());
        chargeStation.setCreateTime(DateUtils.getNowDate());
        return chargeStationMapper.insertChargeStation(chargeStation);
    }

    /**
     * 修改场站
     *
     * @param chargeStation 场站
     * @return 结果
     */
    @Override
    public int updateChargeStation(ChargeStation chargeStation)
    {
        chargeStation.setUpdateBy(getUsername());
        chargeStation.setUpdateTime(DateUtils.getNowDate());
        return chargeStationMapper.updateChargeStation(chargeStation);
    }

    /**
     * 批量删除场站
     *
     * @param chargeStationIds 需要删除的场站主键
     * @return 结果
     */
    @Override
    public int deleteChargeStationByChargeStationIds(Long[] chargeStationIds)
    {
        return chargeStationMapper.deleteChargeStationByChargeStationIds(chargeStationIds);
    }

    /**
     * 删除场站信息
     *
     * @param chargeStationId 场站主键
     * @return 结果
     */
    @Override
    public int deleteChargeStationByChargeStationId(Long chargeStationId)
    {
        return chargeStationMapper.deleteChargeStationByChargeStationId(chargeStationId);
    }

    @Override
    public Map<String, Integer> getStatus(BaseEntity entity) {
        return chargeStationMapper.getStatus(entity);
    }
}
